<?php
/*
|--------------------------------------------------------------------------
| Web Routes: Namespace Admin
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use Illuminate\Contracts\Routing\Registrar as RouteRegisterContract;

Route::domain('admin.'.env('APP_DOMAIN'))->namespace('Admin')->group(function (RouteRegisterContract $route) {
    $route->middleware('normal')->group(function (RouteRegisterContract $route) {
        $route->get('/', 'IndexController@root');

        $route->get('/login', 'AdminController@login')->name('admin/login');

        $route->get('/register', 'AdminController@register')->name('admin/register');

        $route->any('/logout', 'AdminController@logout')->name('admin/logout');
    });

    $route->middleware('admin.auth')->group(function (RouteRegisterContract $route) {
        $route->group(['prefix' => '/index'], function (RouteRegisterContract $route) {
            Route::get('/index', 'IndexController@index')->name('admin/index');
        });

        $route->group(['prefix' => '/adminmenu'], function (RouteRegisterContract $route) {
            $route->get('/index', 'AdminMenuController@index')->name('adminmenu/index');
        });

        $route->group(['prefix' => '/usermenu'], function (RouteRegisterContract $route) {
            $route->get('/index', 'UserMenuController@index')->name('usermenu/index');
        });

        $route->group(['prefix' => '/slider'], function (RouteRegisterContract $route) {
            $route->get('/index', 'SliderController@index')->name('slider/index');
        });

        $route->group(['prefix' => '/adminlog'], function (RouteRegisterContract $route) {
            $route->get('/index', 'AdminLogController@index')->name('adminlog/index');
        });

        $route->group(['prefix' => '/user'], function (RouteRegisterContract $route) {
            $route->get('/index', 'UserController@index')->name('user/index');

            $route->get('/view', 'UserController@view')->name('user/view');
        });

        $route->group(['prefix' => '/album'], function (RouteRegisterContract $route) {
            $route->get('/index', 'AlbumController@index')->name('album/index');
        });

        $route->group(['prefix' => '/test'], function (RouteRegisterContract $route) {
            $route->get('/find', 'TestController@find')->name('test/find');

            $route->get('/finde', 'TestController@find');
        });
    });
});

Route::domain('api.admin.'.env('APP_DOMAIN'))->namespace('Admin')->group(function (RouteRegisterContract $route) {
    $route->middleware('api')->group(function (RouteRegisterContract $route) {
        $route->post('/doLogin', 'AdminController@doLogin');
    });

    $route->middleware('api.admin.auth')->group(function (RouteRegisterContract $route) {
        $route->group(['prefix' => '/adminmenu'], function (RouteRegisterContract $route) {
            $route->post('/add', 'AdminMenuController@add');

            $route->post('/edit', 'AdminMenuController@edit');

            $route->post('/del', 'AdminMenuController@del');
        });

        $route->group(['prefix' => '/usermenu'], function (RouteRegisterContract $route) {
            $route->post('/add', 'UserMenuController@add');

            $route->post('/edit', 'UserMenuController@edit');

            $route->post('/del', 'UserMenuController@del');
        });

        $route->group(['prefix' => '/slider'], function (RouteRegisterContract $route) {
            $route->post('/add', 'SliderController@add');

            $route->post('/edit', 'SliderController@edit');

            $route->post('/del', 'SliderController@del');
        });

        $route->group(['prefix' => '/album'], function (RouteRegisterContract $route) {
            $route->post('/add', 'AlbumController@add');

            $route->post('/edit', 'AlbumController@edit');

            $route->post('/del', 'AlbumController@del');
        });
    });
});
